﻿using FluentValidation;
using FluentValidation.Results;

namespace Customers.Api.Domain.Common;

public static class ExceptionExtensions
{
    public static void ThrowValidationException<T>(this T t, string propertyName, string errorMessage)
        where T : class, new()
    {
        throw new ValidationException(errorMessage, new[]
        {
            new ValidationFailure(propertyName, errorMessage)
        });
    }
}